(function () {

    // 定义一个动物的类 ocp原则
    class Animal {
        name: string;
        age: number;
        constructor(name: string, age: number) {
            this.name = name;
            this.age = age;
        }

        sayHello() {
            console.log(`Hello, my name is ${this.name}`);
        }
    }

    // 定义一个狗的类 继承 动物类
    class Dog extends Animal {
        run() {
            console.log(`${this.name} is running`);
        }
    }

    // 定义一个猫的类  继承 动物类
    class Cat extends Animal { 

    }

    const dog = new Dog('旺财', 3);
    console.log(dog.sayHello()); // 输出：Hello, my name is 旺财
    console.log(dog.run()); // 输出：旺财 is running

    const cat = new Cat('Tom', 2);
    console.log(cat.sayHello()); // 输出：Hello, my name is Tom


})()